<template>
  <div>{{time}}</div>
</template>

<script>
import moment from "moment";
export default {
  props: ["createTime"],

  data() {
    return {
      time: "",
    };
  },  

  created() {  
    this.countDown();
  },
  methods: { 
    countDown() {
      // 剩余时间
      let count = (900000-(Date.now()-this.createTime))/1000;
      count= Math.floor(count);
      let timer = setInterval(()=> {
        // 分钟
        let m = Math.floor(count/60);  
        // 秒钟
        let s = count%60; 
        this.time = m+'分'+s+'秒';
        count=count-1;
        if (count<0) {
          clearInterval(timer);
        }
      },1000)
    },
  },
};
</script>

<style>
</style>